package com.hsxc.cdz.monitor.bean.server.v1_21;

import com.hsxc.cdz.base.util.BytesUtil;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.util.ReferenceCountUtil;

/**
 * 
 * @author 刘力文 服务端下发停止充电的报文类
 */
public class ChargeCeaseSerMsg extends ServerMessage {
	public static final int length = 12;
	private int port; // 充电口号
	private int controll; // 控制类型
	private String cardNum; // 用户卡号

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public int getControll() {
		return controll;
	}

	public void setControll(int controll) {
		this.controll = controll;
	}

	public String getCardNum() {
		return cardNum;
	}

	public void setCardNum(String cardNum) {
		this.cardNum = cardNum;
	}

	@Override
	public byte[] getBytesFromMessage() {
		ByteBuf bytes = Unpooled.buffer(ChargeCeaseSerMsg.length);
		byte[] result;
		byte[] temp;

		temp = BytesUtil.intToBytesSeq(this.getPort(), 1);
		bytes.writeBytes(temp);

		temp = BytesUtil.intToBytesSeq(this.getControll(), 1);
		bytes.writeBytes(temp);

		temp = BytesUtil.strToBcdBytes(this.getCardNum(), 10);
		bytes.writeBytes(temp);

		result = new byte[bytes.readableBytes()];
		bytes.readBytes(result);
		ReferenceCountUtil.release(bytes);
		return result;
	}
}
